﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using Common;

namespace Framework
{
    /// <summary>
    /// 服务异常
    /// </summary>
    [Serializable]
    public class ServicesException : BaseException
    {
        /// <summary>
        /// 构造函数，二进制反序列化时使用
        /// </summary>
        /// <param name="info">序列化对象数据</param>
        /// <param name="context">上下文信息</param>
        protected ServicesException(SerializationInfo info, StreamingContext context)
            : base(info, context) { }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="code">异常编码</param>
        /// <param name="message">异常消息</param>
        public ServicesException(string code, string message)
            : base(code, message)
        {
        }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="message"></param>
        public ServicesException(string message) : base(ExceptionCode.SVC_DEFAULT_EXCEPTIONCODE, message)
        {
        }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="code">异常编码</param>
        /// <param name="message">异常消息</param>
        /// <param name="innerException">嵌套异常类</param>
        public ServicesException(string code, string message, System.Exception innerException)
            : base(code, message, innerException)
        {

        }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="code">异常编码</param>
        /// <param name="innerException">嵌套异常类</param>
        /// <param name="messageFormat">异常消息格式化串</param>
        /// <param name="messageParams">异常消息参数值</param>
        public ServicesException(string code, System.Exception innerException, string messageFormat, params string[] messageParams)
            : base(code, innerException, messageFormat, messageParams)
        {

        }

        /// <summary>
        /// 格式化异常信息内容输出
        /// </summary>
        /// <returns>格式化异常信息内容</returns>
        public override string ToString()
        {
            return "ServicesException: " + Message + " Wrapped exception: " + base.ToString();
        }

    }
}
